import request from "@/utils/request"
import { remoteRequest } from '@/utils/remote.js'

// 添加邮箱
export function saveEmail(data) {
  return request({
    url: '/manage/email/save',
    method: 'post',
    data
  })
}

// 查询邮箱
export function getEmail(params) {
  return request({
    url: '/manage/email/getAll',
    method: 'get',
    params
  })
}

// 邮箱重复性校验
export function checkEmail(email) {
  return remoteRequest('checkEmail', email, () => {
    return request({
      url: `/manage/email/checkEmail/${email}`,
      method: 'get'
    })
  })
}

// 删除邮箱
export function deleteEmail(ids) {
  return request({
    url: `/manage/email/delete/${ids}`,
    method: 'post'
  })
}

const baseUrl = '/dataManage/plotSettings'

// 模板-保存
export function savePlot(data) {
  return request({
    url: `${baseUrl}/save`,
    method: 'post',
    data
  })
}

// 模板-查询
export function getAllPlot(params) {
  return request({
    url: `${baseUrl}/getAll`,
    method: 'get',
    params
  })
}

// 模板-使用
export function operate(data) {
  return request({
    url: `${baseUrl}/operate`,
    method: 'post',
    data
  })
}

// 模板-查看
export function getById(id) {
  return request({
    url: `${baseUrl}/getById/${id}`,
    method: 'get'
  })
}

// 模板-修改
export function updatePlot(data) {
  return request({
    url: `${baseUrl}/update`,
    method: 'post',
    data
  })
}

// 模板-删除
export function deletePlot(ids) {
  return request({
    url: `${baseUrl}/delete/${ids}`,
    method: 'post'
  })
}

// 模板-重复校验
export function duplicateCheck(templateName, id) {
  return remoteRequest('duplicateCheck', { templateName, id }, () => {
    return request({
      url: `${baseUrl}/duplicateCheck`,
      method: 'post',
      data: { id, templateName }
    })
  })
}